package com.scuec.groupfive.mapper;

import com.scuec.groupfive.entity.PracticeRankVO;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface PracticeRankMapper {
    @Select("SELECT " +
            "    ar.user_id, " +
            "    u.username, " +
            "    COUNT(ar.record_id) AS practice_count " +
            "FROM " +
            "    answer_records ar " +
            "JOIN " +
            "    users u ON ar.user_id = u.user_id " +
            "WHERE " +
            "    u.role != 'admin' " +
            "GROUP BY " +
            "    ar.user_id, u.username " +
            "ORDER BY " +
            "    practice_count DESC")
    List<PracticeRankVO> getPracticeRankList();
}